package com.tyrone.leetcode.weekgame;

/**
 * @author yelong.xie
 * @date 2024/2/11 10:51
 */
public class CountMatchingSubarrays {
    public static void main(String[] args) {
        Solution solution = new Solution();
        System.out.println(solution.countMatchingSubarrays(new int[]{1,2,3,4,5,6}, new int[]{1,1}));
    }
    static class Solution {
        /**
         * 这里思路其实是正确的 最后面就变成了字符串匹配 要用到kmp算法但是我不熟悉
         * @param nums
         * @param pattern
         * @return
         */
        public int countMatchingSubarrays(int[] nums, int[] pattern) {
            int n = nums.length;
            int window = pattern.length;

            //预处理
            int[] search = new int[n-1];
            StringBuilder builder = new StringBuilder();
            for (int i = 0; i+1 < nums.length; i++) {
                if (nums[i]<nums[i+1]){
                    search[i] = 1;
                    builder.append(1);
                }else if (nums[i]==nums[i+1]){
                    builder.append(0);
                }else {
                    builder.append(2);
                }
            }
            String searchStr = builder.toString();
            //滑动窗口
            int ans = 0;
            StringBuilder pa = new StringBuilder();
            for (int i = 0; i < window; i++) {
                if (pattern[i] == -1) pa.append(2);
                else pa.append(pattern[i]);
            }
            String paString = pa.toString();

            return ans;
        }

    }
}
